package com.ooono.factorytest.items;

import android.os.Bundle;
import android.os.Vibrator;

import androidx.annotation.Nullable;

import com.ooono.factorytest.R;
import com.ooono.factorytest.base.BaseActivity;

/**
 * 振动测试
 */
public class VibratorTestActivity extends BaseActivity {

    public static final String KEY = "vibrator";

    private Vibrator vibrator;

    @Override
    public int getTestTitle() {
        return R.string.vibrator_test_title;
    }

    @Override
    public String getTestKey() {
        return KEY;
    }

    @Override
    public int getContentLayout() {
        return R.layout.content_vibrator_test;
    }

    @Override
    public void initViews() {
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        vibrator = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);
    }

    @Override
    public void onStart() {
        super.onStart();
        long[] patter = {0, 1000};
        vibrator.vibrate(patter, 0);
    }

    @Override
    public void onStop() {
        vibrator.cancel();
        super.onStop();
    }
}
